<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
  <head>
    <meta charset="utf-8" />
    <meta name="generator" content="pandoc" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, user-scalable=yes"
    />
    <title>README</title>
    <style type="text/css">
      code {
        white-space: pre-wrap;
      }
      span.smallcaps {
        font-variant: small-caps;
      }
      span.underline {
        text-decoration: underline;
      }
      div.column {
        display: inline-block;
        vertical-align: top;
        width: 50%;
      }
    </style>
  </head>
  <body>
    <h1 id="project-euler">Project Euler</h1>
    <p>
      Problems are taken from https://projecteuler.net/, the Project Euler.
      <a href="https://projecteuler.net/copyright"
        >Problems are licensed under CC BY-NC-SA 4.0</a
      >.
    </p>
    <p>
      Project Euler is a series of challenging mathematical/computer programming
      problems that require more than just mathematical insights to solve.
      Project Euler is ideal for mathematicians who are learning to code.
    </p>
    <p>
      The solutions will be checked by our
      <a href="https://travis-ci.com/github/TheAlgorithms/Python/pull_requests"
        >automated testing on Travis CI</a
      >
      with the help of
      <a
        href="https://github.com/TheAlgorithms/Python/blob/master/scripts/validate_solutions.py"
        >this script</a
      >. The efficiency of your code is also checked. You can view the top 10
      slowest solutions on Travis CI logs (under
      <code>slowest 10 durations</code>) and open a pull request to improve
      those solutions.
    </p>
    <h2 id="solution-guidelines">Solution Guidelines</h2>
    <p>
      Welcome to
      <a href="https://github.com/TheAlgorithms/Python">TheAlgorithms/Python</a
      >! Before reading the solution guidelines, make sure you read the whole
      <a
        href="https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md"
        >Contributing Guidelines</a
      >
      as it won’t be repeated in here. If you have any doubt on the guidelines,
      please feel free to
      <a href="https://github.com/TheAlgorithms/Python/issues/new"
        >state it clearly in an issue</a
      >
      or ask the community in
      <a href="https://gitter.im/TheAlgorithms">Gitter</a>. You can use the
      <a
        href="https://github.com/TheAlgorithms/Python/blob/master/project_euler/README.md#solution-template"
        >template</a
      >
      we have provided below as your starting point but be sure to read the
      <a
        href="https://github.com/TheAlgorithms/Python/blob/master/project_euler/README.md#coding-style"
        >Coding Style</a
      >
      part first.
    </p>
    <h3 id="coding-style">Coding Style</h3>
    <ul>
      <li>
        <p>
          Please maintain consistency in project directory and solution file
          names. Keep the following points in mind:
        </p>
        <ul>
          <li>
            Create a new directory only for the problems which do not exist yet.
          </li>
          <li>
            If you create a new directory, please create an empty
            <code>__init__.py</code> file inside it as well.
          </li>
          <li>
            Please name the project <strong>directory</strong> as
            <code>problem_&lt;problem_number&gt;</code> where
            <code>problem_number</code> should be filled with 0s so as to occupy
            3 digits. Example: <code>problem_001</code>,
            <code>problem_002</code>, <code>problem_067</code>,
            <code>problem_145</code>, and so on.
          </li>
        </ul>
      </li>
      <li>
        <p>
          Please provide a link to the problem and other references, if used, in
          the <strong>module-level docstring</strong>.
        </p>
      </li>
      <li>
        <p>
          All imports should come <strong><em>after</em></strong> the
          module-level docstring.
        </p>
      </li>
      <li>
        <p>
          You can have as many helper functions as you want but there should be
          one main function called <code>solution</code> which should satisfy
          the conditions as stated below:
        </p>
        <ul>
          <li>
            It should contain positional argument(s) whose default value is the
            question input. Example: Please take a look at
            <a href="https://projecteuler.net/problem=1">Problem 1</a> where the
            question is to
            <em>Find the sum of all the multiples of 3 or 5 below 1000.</em> In
            this case the main solution function will be
            <code>solution(limit: int = 1000)</code>.
          </li>
          <li>
            When the <code>solution</code> function is called without any
            arguments like so: <code>solution()</code>, it should return the
            answer to the problem.
          </li>
        </ul>
      </li>
      <li>
        <p>
          Every function, which includes all the helper functions, if any, and
          the main solution function, should have <code>doctest</code> in the
          function docstring along with a brief statement mentioning what the
          function is about.
        </p>
        <ul>
          <li>
            <p>
              There should not be a <code>doctest</code> for testing the answer
              as that is done by our Travis CI build using this
              <a
                href="https://github.com/TheAlgorithms/Python/blob/master/project_euler/validate_solutions.py"
                >script</a
              >. Keeping in mind the above example of
              <a href="https://projecteuler.net/problem=1">Problem 1</a>:
            </p>
            <p>
              def solution(limit: int = 1000): """ A brief statement mentioning
              what the function is about.
            </p>
            <pre><code>You can have a detailed explanation about the solution method in the
module-level docstring.

&gt;&gt;&gt; solution(1)
...
&gt;&gt;&gt; solution(16)
...
&gt;&gt;&gt; solution(100)
...
&quot;&quot;&quot;</code></pre>
          </li>
        </ul>
      </li>
    </ul>
    <h3 id="solution-template">Solution Template</h3>
    <p>
      You can use the below template as your starting point but please read the
      <a
        href="https://github.com/TheAlgorithms/Python/blob/master/project_euler/README.md#coding-style"
        >Coding Style</a
      >
      first to understand how the template works.
    </p>
    <p>
      Please change the name of the helper functions accordingly, change the
      parameter names with a descriptive one, replace the content within
      <code>[square brackets]</code> (including the brackets) with the
      appropriate content.
    </p>
    <pre><code>&quot;&quot;&quot;
Project Euler Problem [problem number]: [link to the original problem]

... [Entire problem statement] ...

... [Solution explanation - Optional] ...

References [Optional]:
- [Wikipedia link to the topic]
- [Stackoverflow link]
...

&quot;&quot;&quot;
import module1
import module2
...

def helper1(arg1: [type hint], arg2: [type hint], ...) -&gt; [Return type hint]:
    &quot;&quot;&quot;
    A brief statement explaining what the function is about.

    ... A more elaborate description ... [Optional]

    ...
    [Doctest]
    ...

    &quot;&quot;&quot;
    ...
    # calculations
    ...

    return


# You can have multiple helper functions but the solution function should be
# after all the helper functions ...


def solution(arg1: [type hint], arg2: [type hint], ...) -&gt; [Return type hint]:
    &quot;&quot;&quot;
    A brief statement mentioning what the function is about.

    You can have a detailed explanation about the solution in the
    module-level docstring.

    ...
    [Doctest as mentioned above]
    ...

    &quot;&quot;&quot;

    ...
    # calculations
    ...

    return answer


if __name__ == &quot;__main__&quot;:
    print(f&quot;{solution() = }&quot;)</code></pre>
  </body>
</html>
